package cl.ccs.migracionbcmc.view.pdf;

import com.itextpdf.text.Chunk;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPCell;

public class PdfUtil {


    private static Font.FontFamily font = Font.FontFamily.COURIER; ;
    private static int fontSize = 9;

    public PdfUtil() {
        super();
        
    }
    
    public PdfPCell setDisableBorderTRBL(PdfPCell cell) {
        cell.setBorder(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderTRB(PdfPCell cell) {
        cell.setBorderWidthTop(0);
        cell.setBorderWidthRight(0);
        cell.setBorderWidthBottom(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderTR(PdfPCell cell) {
        cell.setBorderWidthTop(0);
        cell.setBorderWidthRight(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderT(PdfPCell cell) {
        cell.setBorderWidthTop(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderTBL(PdfPCell cell) {
        cell.setBorderWidthTop(0);
        cell.setBorderWidthBottom(0);
        cell.setBorderWidthLeft(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderTB(PdfPCell cell) {
        cell.setBorderWidthTop(0);
        cell.setBorderWidthBottom(0);;
        return cell;
    }
    
    public PdfPCell setDisableBorderTRL(PdfPCell cell) {
        cell.setBorderWidthTop(0);
        cell.setBorderWidthRight(0);
        cell.setBorderWidthLeft(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderTL(PdfPCell cell) {
        cell.setBorderWidthTop(0);
        cell.setBorderWidthLeft(0);
        return cell;
    }
    
    /////////////////////////////////////////////
    
    public PdfPCell setDisableBorderRBL(PdfPCell cell) {
        cell.setBorderWidthRight(0);
        cell.setBorderWidthBottom(0);
        cell.setBorderWidthLeft(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderRL(PdfPCell cell) {
        cell.setBorderWidthRight(0);
        cell.setBorderWidthLeft(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderRB(PdfPCell cell) {
        cell.setBorderWidthRight(0);
        cell.setBorderWidthBottom(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderR(PdfPCell cell) {
        cell.setBorderWidthRight(0);
        return cell;
    }
    
    //////////////////////////////////////////////////
    
    public PdfPCell setDisableBorderBL(PdfPCell cell) {
        cell.setBorderWidthBottom(0);
        cell.setBorderWidthLeft(0);
        return cell;
    }
    
    public PdfPCell setDisableBorderB(PdfPCell cell) {
        cell.setBorderWidthBottom(0);
        return cell;
    }
    
    /////////////////////////////////////////////////
    
    public PdfPCell setDisableBorderL(PdfPCell cell) {
        cell.setBorderWidthLeft(0);
        return cell;
    }
    
    
    public static PdfPCell getCell(String text) {
        return getCell(text, Element.ALIGN_LEFT);
    }
    
    public static PdfPCell getCell(String text, int align){
        return getCell(text, align, Font.NORMAL); 
    }
    
    public static PdfPCell getCell(String text, int align, int border) {
        Font fontLocal = new Font(font, fontSize, border); 
        Chunk chunkText = new Chunk(text, fontLocal); 
        Paragraph paragraph = new Paragraph(chunkText);

        PdfPCell cell = new PdfPCell(paragraph);
        cell.setHorizontalAlignment(align); 
        return cell;
    }


    public void setFont(Font.FontFamily font) {
        this.font = font;
    }

    public Font.FontFamily getFont() {
        return font;
    }

    public static void setFontSize(int fontSize) {
        PdfUtil.fontSize = fontSize;
    }

    public static int getFontSize() {
        return fontSize;
    }
}
